/**
 * @file map_manager.h
 * @author shaojiale
 * @brief
 * @version 0.1
 * @date 2022-07-21
 *
 * @copyright Copyright (c) 2022
 *
 */

#ifndef _H_MAP_MANAGER_H_
#define _H_MAP_MANAGER_H_

#include "map_data.h"

#include <fstream>
#include <string>

#include "document.h"
#include "prettywriter.h"
#include "istreamwrapper.h"
#include "filereadstream.h"

namespace cadmus {
namespace map {
using namespace cadmus::map;
using namespace rapidjson;

/**
 * @brief 地图管理工具
 *
 */
class MapManager
{
  public:
    MapManager()
    {
    }
    MapManager(std::string map_path) : map_path_(map_path)
    {
    }
    void setMapPath(std::string map_path)
    {
        map_path_ = map_path;
    }

    // get
    bool getMark(std::string map_id, std::string layer_id, std::string mark_id);
    bool getMarks(std::string map_id, std::string layer_id);
    bool getLayer(std::string map_id, std::string layer_id);

    std::string getLayers(std::string map_id);
    std::string getGridInfo(std::string map_id);
    int         getGridSize(std::string map_id);

    // bool getGrid(std::string map_id); //TODO 目前不放在这里
    // // set
    // bool set(std::string map_id, std::string layer_id, std::string mark_id);
    // bool setMark(std::string map_id, std::string layer_id, std::string mark_id, MapMark mark);
    // bool setLayer(std::string map_id, std::string layer_id, std::string mark_id, MapMark mark);
    // // add
    // bool add(std::string map_id, std::string layer_id, std::string mark_id);
    // // delete
    // bool del(std::string map_id, std::string layer_id, std::string mark_id);
    // // switch
    // bool switchMap(std::string map_id);
    // // save
    // bool saveMap(std::string map_id);

    //   private:
    Document load_map(std::string map_id);
    Document load_layers(std::string map_id);
    Document load_grid(std::string map_id);
    Document load_grid_info(std::string map_id);

    std::string map_path_;

    MapData current_map_;
};
} // namespace map
} // namespace cadmus

#endif // _H_MAP_MANAGER_H_